from datetime import datetime

from sqlalchemy import Table, Integer, Unicode, Column, DateTime, ForeignKey
from sqlalchemy.orm import mapper

from tortuga.database import metadata
from tortuga.models.util import Base

__all__ = ['WorkflowEvent', 'workflow_event_table', 'WORKFLOW_STATUS']

WORKFLOW_STATUS = dict(
    DRAFT=0,
    PENDING=1,
    APPROVED=2
)

workflow_event_table = Table('workflow_event', metadata,
    Column('workflow_id', Integer, primary_key=True),
    # Column('workflow_author', None, nullable=False),
    Column('timestamp', DateTime, default=datetime.now, nullable=False),
    Column('comment', Unicode(1000), default=u'', nullable=False),
    Column('status', Integer, default=WORKFLOW_STATUS['DRAFT'], nullable=False),
    Column('revision_id', None, ForeignKey('revision.revision_id'), nullable=False)
)

class WorkflowEvent(Base):
    """Represents a workflow event, such as a Page or Photo being published"""
    pass
    
mapper(WorkflowEvent, workflow_event_table)